import axios from 'axios'

// http request拦截器 添加一个请求拦截器
axios.interceptors.request.use(function (config) {
    console.log("1111111111111")
    // Do something before request is sent
    //window.localStorage.getItem("accessToken") 获取token的value
    let token = window.sessionStorage.getItem("token")
    if (token) {
        //将token放到请求头发送给服务器,将tokenkey放在请求头中
        config.headers.Authorization = "Token " + token;
        //也可以这种写法
        // config.headers['accessToken'] = Token;
        return config;
    }
    return config
}, function (error) {
    // Do something with request error
    return Promise.reject(error);
});

export default axios